package menu;

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

/**
 * Lớp các tài nguyên cần cho việc thiết kế menu
 */
class Resources {

    Button buttonStart, buttonExit, buttonAbout, buttonContinue, buttonBack, buttonBackInfo;
    Image mapChoose, titleGame, youWin, youLose, infoAbout;
    Font fontEffect;

    Resources() {

        buttonStart = new Button("start", 300, 200);
        buttonAbout = new Button("about", 300, 300);
        buttonExit = new Button("exit", 300, 400);
        buttonContinue = new Button("continue", 360, 200);
        buttonBack = new Button("back", 360, 200);
        buttonBackInfo = new Button("back_info", 215, 380);
        try {
            fontEffect = Font.createFont(Font.TRUETYPE_FONT, Menu.class.getResourceAsStream("/font/hlcomic.ttf"));
            fontEffect = fontEffect.deriveFont(42.0F);

            titleGame = ImageIO.read(this.getClass().getResourceAsStream("/menu/title_game.png"));
            mapChoose = ImageIO.read(this.getClass().getResourceAsStream("/menu/bg_map_choose.png"));
            youWin = ImageIO.read(this.getClass().getResourceAsStream("/menu/you_win.png"));
            youLose = ImageIO.read(this.getClass().getResourceAsStream("/menu/you_lose.png"));
            infoAbout = ImageIO.read(this.getClass().getResourceAsStream("/menu/info_about.png"));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * Inner button
     */
    class Button {

        private BufferedImage image;
        private int x, y;

        Button(String path, int x, int y) {
            this.x = x;
            this.y = y;
            try {
                image = ImageIO.read(Button.class.getResourceAsStream("/menu/" + path + ".png"));

            } catch (Exception e) {
                System.out.println("buttonGame: " + e.toString());
            }

        }

        protected void paint(Graphics g) {
            g.drawImage(image, x, y, null);

        }

    }

}
